import React from "react";
import Octicons from "octicons";

/**
 * 图标组件
 * @type {{a,b,c,d}}
 */
const Icons = {};
export default Icons;
Object.keys(Octicons).forEach(key=>{
    let icon = Octicons[key];
    Icons[key] = (props)=>{
        let ratio = icon.width / icon.height;
        let width = props.width || (props.height && props.height * ratio) || icon.width;
        let height = props.height || (props.width && props.width / ratio) || icon.height;
        let style = Object.assign({fill: props.fill}, props.style);
        return <svg
            version="1.1"
            style={style}
            className={props.className}
            width={width}
            height={height}
            viewBox={`0 0 ${icon.width} ${icon.height}`}
            dangerouslySetInnerHTML={{__html: icon.path}}/>;
    }
});
